package com.direct.controller;

import com.direct.pojo.Dept;
import com.direct.service.DeptClientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.util.List;

/**
 * @author caixiaofeng
 * @company xxx公司科技有限公司
 * @create 2020-04-21 16:17
 */
@RestController
public class DeptController {
    @Autowired
    private RestTemplate restTemplate;
    @Autowired
    private DeptClientService deptClientService;

    @GetMapping("/dept/{deptno}")
    Dept queryById(@PathVariable("deptno") Long deptno){
        return deptClientService.queryById(deptno);
    }

    @GetMapping("/depts")
    List<Dept> queryAll(){
        return deptClientService.queryAll();
    }

    @PostMapping("/dept")
    void addDept(Dept dept){
        deptClientService.addDept(dept);
    }
}
